import { Button, Popconfirm, Space, TdPrimaryTableProps } from "tdesign-vue-next";
import { Link } from "@arco-design/web-vue";
import { openUpdateLink } from "@/page/setting/pages/link/components/EditLink";

export const linkTableColumn: TdPrimaryTableProps["columns"] = [
  {
    title: "名称",
    colKey: "name",
    width: 120,
    fixed: "left"
  },
  {
    title: "链接",
    colKey: "value",
    width: 260,
    cell: (_h, { row }) => <Link href={row.value}>{row.value}</Link>
  },
  {
    title: "版本",
    colKey: "version"
  },
  {
    title: "认证",
    colKey: "isAuth",
    width: 100,
    cell: (_h, { row }) => <div>{row.is_auth ? "是" : "否"}</div>
  },
  {
    title: "操作",
    colKey: "action",
    width: 170,
    fixed: "right",

    cell: (_h, { row }) => (
      <Space>
        <Button theme={"primary"} onClick={() => openUpdateLink(row as any)}>
          修改
        </Button>
        <Popconfirm confirmBtn={"删除"} content={"是否删除链接，删除后将无法恢复"}>
          <Button theme={"danger"}>删除</Button>
        </Popconfirm>
      </Space>
    )
  }
];
